private static LoadCollectionResponseData get_response_data()
 {
     var data = new LoadCollectionResponseData();
     data.Items.Add(new IDOItem() { ItemID = "1342" });
     data.Items.Add(new IDOItem() { ItemID = "1343" });
     data.Items.Add(new IDOItem() { ItemID = "1344" });
     return data;
 }
Ejemplo n.º 2
0
        public LoadCollectionResponseData getEventStatus(string eventName)
        {
            LoadCollectionRequestData Load = new LoadCollectionRequestData();

            Load.IDOName = "EventStates";
            Load.PropertyList.Add("EventName");
            Load.PropertyList.Add("Status");
            Load.PropertyList.Add("Originator");
            Load.PropertyList.Add("EventParmId");
            Load.Filter    = "EventName = '" + eventName + "' AND Status = '2'";
            Load.OrderBy   = "";
            Load.RecordCap = 100;
            LoadCollectionResponseData response = IDOClient.LoadCollection(Load);

            if (response.Items.Count > 0)
            {
                ThisForm.Variables("varDebug").Value += response[0, "EventName"].Value + "\n";
                ThisForm.Variables("varDebug").Value += response[0, "Status"].Value + "\n";
                ThisForm.Variables("varDebug").Value += response[0, "Originator"].Value + "\n";
                for (int i = 0; i < response.Items.Count; i++)
                {
                    ThisForm.Variables("varDebug").Value += response[i, "EventParmId"].Value + "\n";
                }
            }
            return(response);
        }
Ejemplo n.º 3
0
        public bool isEventRunning(string eventName, string ido)
        {
            LoadCollectionResponseData eventStatusResponse = getEventStatus(eventName);

            if (eventStatusResponse.Items.Count > 0)
            {
                for (int i = 0; i < eventStatusResponse.Items.Count; i++)
                {
                    LoadCollectionResponseData eventOutputParametersResponse = getEventOutputParameters(eventStatusResponse[i, "EventParmId"].Value);

                    if (eventOutputParametersResponse.Items.Count > 0)
                    {
                        ThisForm.Variables("varDebug").Value += "\nEvent running on " + eventOutputParametersResponse[0, "Value"].Value + "\n";

                        if (ido.Equals(eventOutputParametersResponse[0, "Value"].Value))
                        {
                            ThisForm.Variables("varDebug").Value += "\nEvent is already running for " + eventOutputParametersResponse[0, "Value"].Value + "\n";
                            return(true);
                        }
                    }
                }
            }
            else
            {
                ThisForm.Variables("varDebug").Value += "No " + eventName + " event is currently running for " + ido + "\n";
            }

            return(false);
        }
Ejemplo n.º 4
0
        public void LoadDatesandTimes()
        {
            Application.DiagnosticsLog("KC_VarDt:" + ThisForm.Variables("VarDtModified").Value);
            Application.DiagnosticsLog("KC_VarDt:" + ThisForm.Variables("VarDtCreated").Value);

            var currentUser = Application.Variables("VarCRMUserID").GetValueOfString(string.Empty);

            if (string.IsNullOrEmpty(currentUser))
            {
                currentUser = Application.Variables("VarMGUserName").GetValueOfString(string.Empty);
            }
            LoadCollectionResponseData loadResponse = IDOClient.LoadCollection("CRMUserNames", "CRMUserID,LocalTimeZone",
                                                                               string.Format("CRMUserID = '{0}' OR Username = '******'", currentUser), "", 0);
            var timeZone = TimeZoneInfo.Local.Id;

            if (loadResponse.Items.Count > 0)
            {
                timeZone = loadResponse[0, 1].Value;
                Application.DiagnosticsLog(string.Format("User '{0}' time zone set to: {1}", currentUser, timeZone));

                if (string.IsNullOrEmpty(timeZone))
                {
                    // Fall back to local time
                    timeZone = TimeZoneInfo.Local.Id;
                    Application.ShowMessage(Application.GetStringValue("mUserTimeZoneNotSet"));
                }
            }

            var now          = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, timeZone);
            var modifiedDate = ThisForm.Variables("VarDtModified").GetValueOfDateTime(RoundUp(now, TimeSpan.FromMinutes(5)));
            var createdDate  = ThisForm.Variables("VarDtCreated").GetValueOfDateTime(RoundUp(now, TimeSpan.FromMinutes(5)));

            ThisForm.Variables("VarDtModified").SetValue(ConvertDtToTimeZone(modifiedDate, timeZone));
            ThisForm.Variables("VarDtCreated").SetValue(ConvertDtToTimeZone(createdDate, timeZone));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Enable / Disable the Quick Add Product Menu
        /// -- Enable: if BOE is disabled --
        /// -- Disable: if BOE is enabled --
        /// </summary>
        public void EnableDisableProductMenu()
        {
            var integrationCollection = IDOClient.LoadCollection("CRMIntegration", "Enabled", "Name = 'Back Office Extension'", string.Empty, 1);
            int enabled = integrationCollection[0, "Enabled"].GetValue <int>() == 1 ? 0 : 1;

            string filter = string.Format("Action = '{0}'", "CRMQuickAddProduct");
            LoadCollectionResponseData loadResponse = IDOClient.LoadCollection("CRMMenus", "Enabled", filter, string.Empty, 1);

            var updateReq = new UpdateCollectionRequestData()
            {
                IDOName            = "CRMMenus",
                RefreshAfterUpdate = true
            };

            foreach (var current in loadResponse.Items)
            {
                var updateItem = new IDOUpdateItem()
                {
                    ItemID = current.ItemID,
                    Action = UpdateAction.Update
                };

                updateItem.Properties.Add("Enabled", enabled);
                updateReq.Items.Add(updateItem);
            }

            IDOClient.UpdateCollection(updateReq);
        }
Ejemplo n.º 6
0
        private int GetNewRefSeq()
        {
            LoadCollectionResponseData loadResponse = this.IDOClient.LoadCollection(AttachmentSubcollectionName,
                                                                                    "RefSequence",
                                                                                    "", "", 0);

            //Application.ShowMessage("item count = " + loadResponse.Items.Count);
            if (loadResponse.Items.Count > 0)
            {
                List <int> refSeqs = new List <int>();
                foreach (var item in loadResponse.Items)
                {
                    var rs = item.PropertyValues[0].Value;
                    if (!refSeqs.Contains(int.Parse(rs)))
                    {
                        refSeqs.Add(int.Parse(rs));
                    }
                }
                return(refSeqs.Max() + 1);
            }
            else
            {
                return(1);
            }
        }
 static LoadCollectionResponseData get_response_data()
 {
     var data = new LoadCollectionResponseData()
     {
         IDOName = "MyIDOName"
     };
     data.PropertyList.Add("OrderNumber");
     data.Items.Add(get_item());
     return data;
 }
 static LoadCollectionResponseData get_child_collection()
 {
     var data = new LoadCollectionResponseData()
     {
         IDOName = "MyChildIDOName"
     };
     data.PropertyList.Add("OrderNumber");
     data.PropertyList.Add("LineNumber");
     data.Items.Add(get_child_item());
     return data;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Gets the number of activities for the Account. That will be used as badge to display in Activity Related section
        /// </summary>
        public void GetUpcomingActivitiesCount()
        {
            string ActivityCount = "0";
            string accountId     = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID");

            if (accountId != null)
            {
                LoadCollectionResponseData loadresponse = IDOClient.LoadCollection("CRMACCOUNTACTIVITIESRRELATEDVIEWs", "Summary", "EntityID='" + accountId + "' and EntityType='CRMAccount' and Completed IS NULL and IsFirstUncompleted=1", "", -1);
                if (loadresponse != null)
                {
                    ActivityCount = loadresponse.Items.Count == 1 ? "STRINGS(sCRMItemCount)" : string.Format("FORMAT(sCRMItemsCount,{0})", loadresponse.Items.Count.ToString());
                }
            }
            ThisForm.Variables("VarActivityCount").SetValue(ActivityCount);
        }
        static LoadCollectionResponseData get_response()
        {

            var data = new LoadCollectionResponseData();
            data.PropertyList.Add(Customers.CustomerNumber);
            data.PropertyList.Add(Customers.Name);
            var item = new IDOItem() { ItemID = "1342" };
            item.PropertyValues.Add(new IDOPropertyValue("WWTI001"));
            item.PropertyValues.Add(new IDOPropertyValue("WWT"));
            data.Items.Add(item);
            item = new IDOItem() { ItemID = "1343" };
            item.PropertyValues.Add(new IDOPropertyValue("WWTI002"));
            item.PropertyValues.Add(new IDOPropertyValue("WWT2"));
            data.Items.Add(item);
            return data;
        }
Ejemplo n.º 11
0
        public string GetRowPointer(string id, string idoName)
        {
            var rp = "";
            LoadCollectionResponseData resp = this.IDOClient.LoadCollection(
                idoName,
                "RowPointer",
                "ID='" + id +
                "'", "", 0);

            //Application.ShowMessage("count="+resp.Items.Count);
            if (resp.Items.Count > 0)
            {
                //    Application.ShowMessage("value=" + resp.Items[0].PropertyValues[0].Value);
                rp = resp.Items[0].PropertyValues[0].Value;
            }
            //Application.ShowMessage("rp=" + resp.Items[0].PropertyValues[0].Value);
            return(rp);
        }
Ejemplo n.º 12
0
        public string getTableNameFromIdo(string ido)
        {
            LoadCollectionRequestData Load = new LoadCollectionRequestData();

            Load.IDOName = "IdoTables";
            Load.PropertyList.Add("TableName");
            Load.Filter    = "CollectionName = '" + ido + "'";
            Load.OrderBy   = "";
            Load.RecordCap = 1;
            LoadCollectionResponseData idoResponse = Context.Commands.LoadCollection(Load);

            if (idoResponse.Items.Count <= 0)
            {
                return(null);
            }
            else
            {
                return(idoResponse[0, "TableName"].Value);
            }
        }
Ejemplo n.º 13
0
        public LoadCollectionResponseData getEventOutputParameters(string eventParmId)
        {
            LoadCollectionRequestData Load = new LoadCollectionRequestData();

            Load.IDOName = "EventOutputParameters";
            Load.PropertyList.Add("Name");
            Load.PropertyList.Add("Value");
            Load.PropertyList.Add("Originator");
            Load.PropertyList.Add("EventParmId");
            Load.PropertyList.Add("EventName");
            Load.Filter    = "EventParmId = '" + eventParmId + "'";
            Load.OrderBy   = "";
            Load.RecordCap = 10;
            LoadCollectionResponseData response = IDOClient.LoadCollection(Load);

            //ThisForm.Variables("varDebug").Value += "\n\nEvent Output Parameters\n";
            //ThisForm.Variables("varDebug").Value += response[0, "EventName"].Value + "\n";
            //ThisForm.Variables("varDebug").Value += response[0, "EventParmId"].Value + "\n";
            //ThisForm.Variables("varDebug").Value += response[0, "Originator"].Value + "\n";

            return(response);
        }
       private static LoadCollectionResponseData get_response_data()
       {
           var customerOrderResponseData = new LoadCollectionResponseData();
           var customerOrderLineResponseData = new LoadCollectionResponseData();
           customerOrderLineResponseData.Items.Add(new IDOItem());
           customerOrderLineResponseData.IDOName = "SLCoitems";

           customerOrderResponseData.Items.Add(new IDOItem());


           customerOrderResponseData.Items[0].AddNestedResponse(customerOrderLineResponseData);
           return customerOrderResponseData;
        }
Ejemplo n.º 15
0
        public void idoLoad()
        {
            LogMessage("idoLoad");
            LoadCollectionRequestData Load = new LoadCollectionRequestData();

            Load.IDOName = ido;

            //ONE PROPERTY
            if (!properties.Contains(","))
            {
                Load.PropertyList.Add(properties);
            }
            else
            {
                string[] fields = properties.Split(',');
                for (int i = 0; i < fields.Length; i++)
                {
                    //LogMessage(fields[i]);
                    Load.PropertyList.Add(fields[i]);
                }
            }

            Load.Filter    = filter;
            Load.OrderBy   = orderBy;
            Load.RecordCap = recordCap;

            string result = String.Empty;

            stopwatch.Start();
            LogMessage("After stopwatch");

            LoadCollectionResponseData response = null;

            try {
                response = Context.Commands.LoadCollection(Load);
            } catch (Exception e) {
                LogMessage("Failed to load " + ido + "\n" + e.Message);
            }

            LogMessage("After load");
            if (response.Items.Count <= 0)
            {
                LogMessage(ido + " was not found");
            }
            else
            {
                for (int i = 0; i < response.Items.Count; i++)
                {
                    for (int j = 0; j < fields.Length; j++)
                    {
                        try {
                            result += response[i, fields[j]].Value + " " + response.Items[i].ItemID + "\n";
                        } catch (Exception e) {
                            LogMessage("Exception at row " + i + " column " + j + "\n" + e.Message);
                        }
                    }
                    result += "\n\n";
                }
            }

            stopwatch.Stop();
            idoLoadTime = timeElapsed(stopwatch);
            stopwatch.Reset();

            LogMessage(result);
        }
Ejemplo n.º 16
0
        public void AttachmentDialog()
        {
            if (ThisForm.LastModalChildEndedOk)
            {
                var modalFormContext = ThisForm.ModalChildForm.Variables("VarModalContext").GetValueOfString(string.Empty).ToLower();
                if (modalFormContext == ("CRMDialogAttachmentManager").ToLower())
                {
                    var isNew               = ThisForm.ModalChildForm.Variables("VarNew").Value;
                    var docFullName         = ThisForm.ModalChildForm.Components["txtDocumentFullName"].Value;
                    var docType             = Application.GetStringValue(ThisForm.ModalChildForm.Variables("VarDocType").Value);
                    var description         = ThisForm.ModalChildForm.Components["txtDescription"].Value;
                    var tableName           = ThisForm.ModalChildForm.Components["txtTableName"].Value;
                    var fileSpec            = ThisForm.ModalChildForm.Components["txtFileSpec"].Value;
                    var docName             = ThisForm.ModalChildForm.Variables("DocumentName").Value;
                    var docExtension        = ThisForm.ModalChildForm.Variables("DocumentExtension").Value;
                    var docObject           = ThisForm.ModalChildForm.Variables("VarDocumentObject").Value;
                    var refSquence          = ThisForm.ModalChildForm.Components["crmRefSequence"].Value;
                    var docObjectRowPointer = ThisForm.ModalChildForm.Variables("VarCurrentDocumentObjectRowPointer")
                                              .Value;// ThisForm.ModalChildForm.Components["crmDocumentObjectRowPointer"].Value;

                    //Application.ShowMessage("docRP=" + docObjectRowPointer);
                    //Application.ShowMessage("TableName=" + tableName);
                    //Application.ShowMessage(((tableName.ToLower() == "CRMCalendar".ToLower())).ToString());
                    //Application.ShowMessage("IsNew=" + isNew);
                    //AttachmentUpload(tableName, fileSpec, docType, description, docName, docExtension, docObject,
                    //    isNew == "1");
                    ThisForm.PrimaryIDOCollection.RefreshKeepCurIndex();

                    //Application.ShowMessage(((tableName.ToLower() == "CRMCalendar".ToLower()) & (isNew == "1")).ToString());

                    if (isNew == "1")
                    {
                        if ((tableName.ToLower() == "CRMContact".ToLower()) && (isNew == "1"))
                        {
                            //Application.ShowMessage("accountid=" +
                            //                        ThisForm.PrimaryIDOCollection
                            //                            .GetCurrentObjectProperty("AccountID"));
                            //Application.ShowMessage("actrowpointer=" +
                            //                        ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty(
                            //                            "AccountRowPointer"));
                            var rp = GetRowPointer(
                                ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("AccountID"), "CRMAccount");

                            //Application.ShowMessage("rp=" + rp);
                            if (!string.IsNullOrEmpty(rp))
                            {
                                AttachAdditionalAttachments(
                                    refSquence,
                                    docObjectRowPointer,
                                    "CRMAccount",
                                    rp);
                            }
                        }
                        else if ((tableName.ToLower() == "CRMCalendar".ToLower()) && (isNew == "1"))
                        {
                            //Application.ShowMessage("here");
                            //var collectionAssociation =
                            //    ThisForm.PrimaryIDOCollection.GetSubCollection("CRMCalendarAssociation", -1);
                            //int numOfEntires = collectionAssociation.GetNumEntries();


                            LoadCollectionResponseData loadResponseAssociationTable = this.IDOClient.LoadCollection(
                                "CRMCalendarAssociation",
                                "EntityType,EntityID,CalendarID",
                                "CalendarID = '" + ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID") +
                                "'", "", 0);

                            int numOfEntires = loadResponseAssociationTable.Items.Count;
                            //Application.ShowMessage("Count=" + numOfEntires);
                            //Application.ShowMessage("currentid=" +
                            //                        ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ID"));
                            List <string> uniqueEntities = new List <string>();
                            if (numOfEntires > 0)
                            {
                                //Application.ShowMessage("in numOfEntries = " + numOfEntires);
                                for (int i = 0; i < numOfEntires; i++)
                                {
                                    var associateTableName =
                                        loadResponseAssociationTable.Items[i].PropertyValues[0].Value;
                                    var associateEntityID =
                                        loadResponseAssociationTable.Items[i].PropertyValues[1].Value;
                                    var calendarID = loadResponseAssociationTable.Items[i].PropertyValues[2].Value;

                                    if (uniqueEntities.Contains(associateTableName + "-" + associateEntityID))
                                    {
                                        continue;
                                    }
                                    uniqueEntities.Add(associateTableName + "-" + associateEntityID);
                                    LoadCollectionResponseData loadResponse = this.IDOClient.LoadCollection(
                                        associateTableName,
                                        "RowPointer",
                                        "ID = '" + associateEntityID +
                                        "'", "", 0);
                                    //Application.ShowMessage("item count = " + loadResponse.Items.Count);
                                    if (loadResponse.Items.Count > 0)
                                    {
                                        var rp = loadResponse.Items[0].PropertyValues[0].Value;
                                        AttachAdditionalAttachments(
                                            GetNewRefSeq().ToString(),
                                            docObjectRowPointer,
                                            associateTableName,
                                            rp
                                            );
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ForceAttachmentRefresh(ThisForm.PrimaryIDOCollection);
                    }
                }
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Insert trxHeader record with approval of adjustments
        /// Insert all trxLine record with adjustments under trxHeader
        /// </summary>
        public void Submit()
        {
            string trxHeaderIdoName = "CRMWarehouseLocationTrxHeader";
            string trxType          = "StockAdjust";
            string todayDate        = DateTime.UtcNow.ToString("yyyy-MM-ddThh:mm:ss.fffZ");
            string stockBin         = ThisForm.Variables("VarStockBin").Value;

            //INSERT TRX HEADER RECORD
            UpdateCollectionRequestData insert = new UpdateCollectionRequestData(trxHeaderIdoName);
            IDOUpdateItem itm = new IDOUpdateItem(UpdateAction.Insert);

            itm.Properties.Add("TrxType", trxType);
            itm.Properties.Add("TrxDate", todayDate);
            itm.Properties.Add("VanStockLocation", stockBin);
            itm.Properties.Add("Status", "Posted");
            insert.Items.Add(itm);

            try {
                IDOClient.UpdateCollection(insert);
            } catch (Exception e) {
                Application.ShowMessage("Unable to insert record to " + trxHeaderIdoName + "\n" + e.Message);
            }

            Application.ShowMessage("Successfully submitted TrxHeader at " + todayDate);

            //GET TRX HEADER ID FOR TRX LINES
            LoadCollectionRequestData trxHeaderLoadRequest = new LoadCollectionRequestData();

            trxHeaderLoadRequest.IDOName = trxHeaderIdoName;
            trxHeaderLoadRequest.PropertyList.Add("ID");
            trxHeaderLoadRequest.Filter    = "TrxDate = '" + todayDate + "'";
            trxHeaderLoadRequest.OrderBy   = "";
            trxHeaderLoadRequest.RecordCap = 1;
            LoadCollectionResponseData trxHeaderLoadResponse = IDOClient.LoadCollection(trxHeaderLoadRequest);

            if (trxHeaderLoadResponse.Items.Count != 1)
            {
                Application.ShowMessage("Could not load " + trxHeaderIdoName + " record with TrxDate = " + todayDate);
                return;
            }

            //INSERT TRX LINE RECORD
            insert = new UpdateCollectionRequestData("CRMWarehouseStockLotLocationTrx");

            ThisForm.PrimaryIDOCollection.First();
            for (int i = 0; i < ThisForm.PrimaryIDOCollection.GetNumEntries() - 1; i++)
            {
                string trxHeader      = trxHeaderLoadResponse[0, "ID"].Value;
                string productID      = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("ProductID");
                string locationID     = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("LocationID");
                string lotCode        = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("StockLotCode");
                string systemQuantity = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("QuantityOnHand");
                string adjustment     = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("Adjustment");
                string reason         = ThisForm.PrimaryIDOCollection.GetCurrentObjectProperty("Reason");

                Application.ShowMessage(productID + "\n" + locationID + "\n" + lotCode + "\n" + systemQuantity + "\n" + adjustment + "\n" + reason);

                //if adjustment is empty, skip
                if (adjustment.Equals(""))
                {
                    ThisForm.PrimaryIDOCollection.Next();
                    continue;
                }

                itm = new IDOUpdateItem(UpdateAction.Insert);
                itm.Properties.Add("TrxHeader", trxHeader);
                itm.Properties.Add("ProductID", productID);
                itm.Properties.Add("LocationID", locationID);
                itm.Properties.Add("StockLotCode", lotCode);
                itm.Properties.Add("QuantityOnHand", systemQuantity);
                itm.Properties.Add("CountAdjustment", adjustment);
                itm.Properties.Add("Reason", reason);
                insert.Items.Add(itm);

                ThisForm.PrimaryIDOCollection.Next();
            }

            try {
                IDOClient.UpdateCollection(insert);
            } catch (Exception e) {
                Application.ShowMessage("Unable to insert into CRMWarehouseStockLotLocationTrx\n" + e.Message);
            }
        }
 public LoadCollectionResponseWrapper(LoadCollectionResponseData responseData)
 {
     IDOName = responseData.IDOName;
     _records = responseData.BuildChildResponseWrappers();
     _keys = responseData.PropertyList.List;
 }