Beispiel #1
0
        public HttpResponseMessage Signup(SignupRequestInfo signupRequestInfo)
        {
            OrgCust     newCustomer = new OrgCust();
            OrgReseller newReseller = new OrgReseller();


            try
            {
                var rolename = 0;

                bool isNewCustomer = signupRequestInfo.userType == "RESE" ? false : true;

                var orgCustomerType = _IOrgtypService.GetOrgtyps().Where(p => p.TypCd == SystemConstants.ORG_TYPE_CD_CUSTOMER).FirstOrDefault();
                var orgResellerType = _IOrgtypService.GetOrgtyps().Where(p => p.TypCd == SystemConstants.ORG_TYPE_CD_RESELLER).FirstOrDefault();

                var newOrg = _IOrgService.GetOrgs().Where(p => p.soKey == Guid.Parse(signupRequestInfo.id)).FirstOrDefault();
                if (newOrg == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Invalid Invitation"));
                }

                Locn newLocn = new Locn
                {
                    AddressLine1  = signupRequestInfo.addressStreet1,
                    AddressLine2  = signupRequestInfo.addressStreet2,
                    City          = signupRequestInfo.addressCity,
                    DateLastMaint = DateTime.UtcNow,
                    CreateDate    = DateTime.UtcNow,
                    State         = signupRequestInfo.addressState,
                    ZipCode       = signupRequestInfo.addressZip
                };

                var os = _IOrgtyporgstatusService.GetOrgtyporgstatus().Where(p => p.OrgStatus.StatusCd == "INREVIEW").FirstOrDefault();
                newOrg.OrgStatusHists.Add(new OrgStatusHist()
                {
                    Org = newOrg, OrgTypOrgStatu = os, CreateDate = DateTime.UtcNow
                });

                //  Associate Organization to Location
                newOrg.OrgLocns.Add(new OrgLocn {
                    Locn = newLocn, Org = newOrg
                });

                //  Created New OrgCust or OrgReseller based on request
                if (isNewCustomer)
                {
                    rolename = 2;
                }
                else
                {
                    rolename = 3;
                }

                _IOrgService.UpdateOrg(newOrg);

                // Create User
                var newuser = _IUserService.GetUsers().Where(p => p.UserName == signupRequestInfo.email).FirstOrDefault();
                var ctype   = _IContacttypService.GetContacttyps().Find(p => p.ContactTypCd == "PHON");
                var contact = new Contact {
                    ContactTyp = ctype, Value = signupRequestInfo.phone
                };

                var curDateTime = DateTime.UtcNow;
                var guid        = Guid.NewGuid();

                if (newuser.Per == null)
                {
                    Per per = new Per()
                    {
                        FirstName = signupRequestInfo.firstName, LastName = signupRequestInfo.lastName, MiddleName = signupRequestInfo.middleName, Createdate = curDateTime, Title = signupRequestInfo.contactTitle
                    };
                    newuser.Per = per;
                }
                else
                {
                    newuser.Per.FirstName  = signupRequestInfo.firstName;
                    newuser.Per.MiddleName = signupRequestInfo.middleName;
                    newuser.Per.LastName   = signupRequestInfo.lastName;
                    newuser.Per.Title      = signupRequestInfo.contactTitle;
                }

                newuser.Per.PersContacts.Add(new PersContact()
                {
                    Per = newuser.Per, Contact = contact
                });

                var authrole = _IAuthrolService.GetAuthrol(rolename);

                newuser.UserAuthRols.Add(new UserAuthRol()
                {
                    User = newuser, AuthRol = authrole
                });
                newuser.InactiveDate = null;
                newuser.InviteDate   = null;

                var messagetemp = _IMessagetemplateService.GetMessagetemplates().Where(p => p.Name == "SignupAccepted").FirstOrDefault();
                var baseUrl     = Request.RequestUri.GetLeftPart(UriPartial.Authority);

                if (messagetemp != null)
                {
                    newuser.MessageUsers.Add(new MessageUser()
                    {
                        User = newuser, DeliveryMethodId = 1, Message = new Message()
                        {
                            CreateDate = curDateTime, HeaderText = messagetemp.HeaderText, MessageBody = messagetemp.TemplateText + "\n" + baseUrl + "/login"
                        }
                    });
                }

                _IUserService.UpdateUser(newuser);
                _IUserService.UpdatePassword(signupRequestInfo.email, PasswordHash.CreateHash(signupRequestInfo.password));

                // Create Sign Up Workflow
                WkflowDef signUpWorkflow;
                int       wkflowDefId = isNewCustomer ? 1 : 2; // 1= customer signup , 2 = reseller signup
                signUpWorkflow = _IWkflowdefService.GetWkflowdefs().Where(p => p.Id == wkflowDefId).FirstOrDefault();

                var signUpWorkflowInstance = new WkflowInstance
                {
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowDefId      = signUpWorkflow.Id,
                    OrgId            = newOrg.Id,
                    UserId           = 1,
                    CurrWkflowStatId = 5//InReview State
                };

                signUpWorkflowInstance.WkflowStepHists.Add(new WkflowStepHist
                {
                    CreateDate    = DateTime.UtcNow,
                    DateLastMaint = DateTime.UtcNow,
                    WkflowStatId  = 5,
                    CreatedUserId = 1
                });


                _IWkflowinstanceService.AddWkflowinstance(signUpWorkflowInstance);

                return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
            }
            catch (Exception daExp)
            {
                return(Request.CreateResponse <bool>(HttpStatusCode.InternalServerError, false));
            }
        }
Beispiel #2
0
        public HttpResponseMessage FileUpload(int docTypeId, bool test)
        {
            try
            {
                int userID  = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault());
                var org     = _IUserService.GetUser(userID).OrgUsers.Where(p => p.Type == null || p.Type.Contains("Primary")).FirstOrDefault().Org;
                var docType = org.OrgDocTyps.Where(p => p.Id == docTypeId).FirstOrDefault();
                var path    = "";
                System.Web.HttpFileCollection hfc = System.Web.HttpContext.Current.Request.Files;
                int    iUploadedCnt = 0;
                string fileName     = "";
                var    guid         = org.soKey;
                Guid   parentGuid   = Guid.Empty;

                if (org.Id != 1)
                {
                    parentGuid = org.OrgOrgs1.FirstOrDefault().Org.soKey;
                }

                #region Upload to Blob

                var status        = "";
                var storageKey    = Guid.NewGuid();
                var storageAccess = _IPortsettingService.GetPortsettings().Where(p => p.PortId == 1 && p.Setting.Name == "StorageAccess").FirstOrDefault().PortSettingValues.FirstOrDefault().Value;
                //var storageContainer = _IPortsettingService.GetPortsettings().Where(p => p.PortId == 1 && p.Setting.Name == "StorageContainer").FirstOrDefault().PortSettingValues.FirstOrDefault().Value;
                var versionData = new VersionData();
                versionData.container  = guid.ToString();
                versionData.accountKey = storageAccess;
                var success = false;
                for (int iCnt = 0; iCnt <= hfc.Count - 1; iCnt++)
                {
                    System.Web.HttpPostedFile hpf = hfc[iCnt];

                    if (hpf.ContentLength > 0)
                    {
                        BinaryReader b       = new BinaryReader(hpf.InputStream);
                        byte[]       binData = b.ReadBytes(hpf.ContentLength);

                        success      = BlobImage.UploadImage(hpf.FileName, binData, storageKey.ToString() + ".UPL", versionData, org.soKey.ToString(), hpf.FileName);
                        fileName     = hpf.FileName;
                        iUploadedCnt = iUploadedCnt + 1;
                    }
                }
                #endregion


                if (iUploadedCnt > 0 && success)
                {
                    status = iUploadedCnt + " Files Uploaded Successfully";

                    var batchProcessingWorkflow =
                        _IWkflowdefService.GetWkflowdefs().Where(p => p.Code == "FPW").FirstOrDefault();

                    var UploadingstatusID = batchProcessingWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code == "UPLOADED").FirstOrDefault().WkflowStatId;

                    // Create a new batch processing workflow
                    var batchWkflowInstance = new WkflowInstance
                    {
                        CreateDate       = DateTime.UtcNow,
                        DateLastMaint    = DateTime.UtcNow,
                        WkflowDefId      = batchProcessingWorkflow.Id,
                        OrgId            = org.Id,
                        UserId           = userID,
                        CurrWkflowStatId = UploadingstatusID
                    };

                    // Set INIT state for new workflow instance.
                    batchWkflowInstance.WkflowStepHists.Add(new WkflowStepHist
                    {
                        CreateDate    = DateTime.UtcNow,
                        DateLastMaint = DateTime.UtcNow,
                        WkflowStatId  = UploadingstatusID,
                        CreatedUserId = userID
                    });


                    var wkflowInstanceDoc = new WkflowInstanceDoc
                    {
                        WkflowInstanceId = batchWkflowInstance.Id,
                        Doc = new soUpload
                        {
                            Name                     = fileName,
                            Descript                 = fileName,
                            soFileName               = fileName,
                            OrgDocTypId              = docTypeId,
                            soStorageLocation        = path,
                            soStorageKey             = storageKey.ToString() + ".UPL",
                            soStorageContainer       = guid.ToString(),
                            soUploadApp              = "WebPortal",
                            soUploadAppVersion       = "1.0.0.0",
                            soUploadDurationMS       = 10,
                            soStorageType            = "Local",
                            soFormType               = docType.Descript,
                            soFormTypesKey           = docType.soKey,
                            soUserData               = "",
                            soUploadTime             = DateTime.UtcNow,
                            soKey                    = storageKey,
                            soMethod                 = "Web",
                            soWorkstation            = "Portal",
                            soOrganizationsKey       = guid,
                            soParentOrganizationsKey = parentGuid,
                            soUserID                 = userID.ToString(),
                            OrgId                    = org.Id,
                            FileTypeId               = 2,
                            FileExt                  = Path.GetExtension(fileName),
                            soTest                   = test
                        }
                    };

                    batchWkflowInstance.WkflowInstanceDocs.Add(wkflowInstanceDoc);
                    _IWkflowinstanceService.AddWkflowinstance(batchWkflowInstance);
                }
                else
                {
                    var createresponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Upload Failed");
                    throw new HttpResponseException(createresponse);
                }
                return(Request.CreateResponse <string>(HttpStatusCode.OK, status));
            }
            catch
            {
                var createresponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Upload Failed");
                throw new HttpResponseException(createresponse);
            }
        }
Beispiel #3
0
        public HttpResponseMessage Create(SOWDTO requestInfo)
        {
            try
            {
                var SOWWorkflow =
                    _IWkflowdefService.GetWkflowdefs().Find(p => p.Code == "SOW");

                int userID = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault());

                var CreatedstatusID = SOWWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code.Contains("Created")).FirstOrDefault().WkflowStatId;

                int?orgid;

                if (requestInfo.OrgId != null)
                {
                    orgid = requestInfo.OrgId;
                }
                else
                {
                    orgid = _IUserService.GetUser(userID).OrgUsers.Where(p => p.Type == null || p.Type.Contains("Primary")).FirstOrDefault().OrgId;
                }


                var org      = _IOrgService.GetOrg((int)orgid);
                int?ccuserid = org.OrgUsers.Where(p => p.Type == "CustomerCare").Count() > 0 ? (int?)org.OrgUsers.Where(p => p.Type == "CustomerCare").FirstOrDefault().UserId : null;

                var WKflow = new WkflowInstance()
                {
                    Org              = org,
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowDef        = SOWWorkflow,
                    UserId           = userID,
                    CurrWkflowStatId = CreatedstatusID,
                    CCUserId         = ccuserid
                };

                var hist = new WkflowStepHist
                {
                    CreateDate    = DateTime.UtcNow,
                    DateLastMaint = DateTime.UtcNow,
                    WkflowStatId  = CreatedstatusID,
                    CreatedUserId = userID
                };
                var sowWkflow = new SowWkflow
                {
                    WkflowInstance    = WKflow,
                    ProjectName       = requestInfo.ProjectName,
                    Amend             = 0,
                    EffectiveDate     = DateTime.UtcNow,
                    LastReviewDate    = DateTime.UtcNow,
                    NextReviewDate    = DateTime.UtcNow.AddMonths(6),
                    MonthlyCommitment = requestInfo.Commitment
                };

                foreach (var attrib in requestInfo.Attribs)
                {
                    //var newatt = new SowWklowSowAttribute() { SowAttributeId = attrib.Id, SowWkflow = sowWkflow };
                    //newatt.SowAttributeValueHists.Add(new SowAttributeValueHist() { SowWklowSowAttribute = newatt, EffectiveDate = DateTime.UtcNow, SowAttributeId = attrib.Id, Qty = attrib.Qty, UnitPrice = attrib.UnitPrice, ExtendedPrice = attrib.ExtendedPrice });
                    //sowWkflow.SowWklowSowAttributes.Add(newatt);

                    var newatt = new SowWklowSowAttribute()
                    {
                        SowAttributeId = attrib.Id, SowWkflow = sowWkflow
                    };
                    newatt.SowAttributeValueHists.Add(new SowAttributeValueHist()
                    {
                        SowWklowSowAttribute = newatt, EffectiveDate = DateTime.UtcNow, Qty = attrib.Qty, UnitPrice = attrib.UnitPrice, ExtendedPrice = attrib.ExtendedPrice
                    });
                    sowWkflow.SowWklowSowAttributes.Add(newatt);
                }

                foreach (var docSetup in requestInfo.DocSetups)
                {
                    sowWkflow.SowWkflowDocSetups.Add(new SowWkflowDocSetup()
                    {
                        DocumentName = docSetup.Name, SowWkflow = sowWkflow, NoIndexes = docSetup.NoIndexes, NoDataFields = docSetup.NoDataFields, SLA = docSetup.SLA, Volume = docSetup.CommitVolume, ListPrice = docSetup.UnitPrice
                    });
                }

                if (requestInfo.RebateOverride)
                {
                    var reseller = org.OrgOrgs1.FirstOrDefault().Org.OrgReseller;
                    sowWkflow.SOWWkflowOrgResellerDiscOverrides.Add(new SOWWkflowOrgResellerDiscOverride {
                        Discount = requestInfo.ResellerRebate, EffectiveDate = DateTime.UtcNow, SowWkflow = sowWkflow, OrgReseller = reseller
                    });
                }

                WKflow.SowWkflows.Add(sowWkflow);
                WKflow.WkflowStepHists.Add(hist);
                _IWkflowinstanceService.AddWkflowinstance(WKflow);
                return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }
        public HttpResponseMessage Create(DocTypDTO docTypeDTO)
        {
            try
            {
                int userID   = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault());
                int statusID = _IDoctypstatusService.GetDoctypstatus().Where(p => p.StatusCd == "INREVIEW").FirstOrDefault().Id;

                var sameNames = _IOrgdoctypService.GetOrgdoctyps().Where(p => p.OrgId == docTypeDTO.OrgId && p.Descript == docTypeDTO.Descript);

                if (sameNames.Count() <= 0)
                {
                    var DocTypWorkflowdef =
                        _IWkflowdefService.GetWkflowdefs().Where(p => p.Code == "DTSW").FirstOrDefault();

                    var wkstatusID = DocTypWorkflowdef.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code == "INREVIEW").FirstOrDefault().WkflowStatId;

                    var messagetemp = _IMessagetemplateService.GetMessagetemplates().Where(p => p.Name == "NewDocTypeSetup").FirstOrDefault();

                    var user = _IUserService.GetUser(userID);

                    // Create a new Document Type Setup workflow
                    var batchWkflowInstance = new WkflowInstance
                    {
                        CreateDate       = DateTime.UtcNow,
                        WkflowDefId      = DocTypWorkflowdef.Id,
                        OrgId            = docTypeDTO.OrgId,
                        User             = user,
                        CurrWkflowStatId = wkstatusID
                    };

                    // Set INIT state for new workflow instance.
                    batchWkflowInstance.WkflowStepHists.Add(new WkflowStepHist
                    {
                        CreateDate    = DateTime.UtcNow,
                        WkflowStatId  = wkstatusID,
                        CreatedUserId = userID
                    });

                    if (messagetemp != null)
                    {
                        _IMessageuserService.AddMessageuser(new MessageUser()
                        {
                            User = user, DeliveryMethodId = 1, Message = new Message()
                            {
                                CreateDate = DateTime.UtcNow, WkflowInstance = batchWkflowInstance, HeaderText = messagetemp.HeaderText, MessageBody = string.Format(messagetemp.TemplateText, docTypeDTO.Name)
                            }
                        });
                    }

                    _IWkflowinstanceService.AddWkflowinstance(batchWkflowInstance);
                    _IOrgdoctypService.CreateNewDocType(docTypeDTO, userID, statusID);
                    _UnitOfWork.Commit();
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "DocType Name Should be Unique"));
                }
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
        }
Beispiel #5
0
        public HttpResponseMessage Create(SupportActivityDTO requestInfo)
        {
            try
            {
                var supportRequestWorkflow =
                    _IWkflowdefService.GetWkflowdefs().Find(p => p.Code == "SRW");

                int userID = int.Parse(Request.Headers.GetValues("userId").FirstOrDefault());

                //var createdstatusID = supportRequestWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code.Contains("Created")).FirstOrDefault().WkflowStatId;

                var ccstatusID = supportRequestWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code.Contains("Assigned to CustomerCare")).FirstOrDefault().WkflowStatId;
                var cstatusID  = supportRequestWorkflow.WkflowDefWkflowStats.Where(p => p.WkflowStat.Code.Contains("Assigned to Customer")).FirstOrDefault().WkflowStatId;

                int?orgid;

                if (requestInfo.OrgId != null)
                {
                    orgid = requestInfo.OrgId;
                }
                else
                {
                    orgid = _IUserService.GetUser(userID).OrgUsers.Where(p => p.Type == null || p.Type.Contains("Primary")).FirstOrDefault().OrgId;
                }

                var statusID = 0;

                var org = _IOrgService.GetOrg((int)orgid);

                if (org.OrgTyp.TypCd == "TENA")
                {
                    statusID = cstatusID;
                }
                else
                {
                    statusID = ccstatusID;
                }

                int?ccuserid = org.OrgUsers.Where(p => p.Type == "CustomerCare").Count() > 0 ? (int?)org.OrgUsers.Where(p => p.Type == "CustomerCare").FirstOrDefault().UserId : null;

                // Create a new batch processing workflow
                var supportWkflowInstance = new WkflowInstance
                {
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowDefId      = supportRequestWorkflow.Id,
                    OrgId            = orgid,
                    UserId           = userID,
                    CurrWkflowStatId = statusID,
                    Summary          = requestInfo.Summary,
                    Priority         = requestInfo.Priority,
                    CCUserId         = ccuserid
                };

                var hist = new WkflowStepHist
                {
                    CreateDate       = DateTime.UtcNow,
                    DateLastMaint    = DateTime.UtcNow,
                    WkflowStatId     = statusID,
                    CreatedUserId    = userID,
                    WkflowStatReasId = requestInfo.ReasonId
                };

                hist.WkflowStepNotes.Add(new WkflowStepNote()
                {
                    CreatedDate = DateTime.UtcNow, NoteText = requestInfo.NewMessage
                });
                supportWkflowInstance.WkflowStepHists.Add(hist);
                _IWkflowinstanceService.AddWkflowinstance(supportWkflowInstance);
                return(Request.CreateResponse <bool>(HttpStatusCode.OK, true));
            }
            catch (Exception e)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }